﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SyndicateDAO.Classes;
using SyndicateDAO.DatabaseObject;

namespace SyndicateDAO.DAO
{
    public class DrawDAO : DataBaseHelper<draw>
    {
        public IQueryable<draw> SelectAllBySyndicateId(int sId)
        {
            return this.SelectAll().Where(d => d.syndicateId == sId);
        }

        public IQueryable<draw> SelectAllBySyndicateId(DataContext dc,int sId)
        {
            return this.SelectAll(dc).Where(d => d.syndicateId == sId);
        }

        public draw SelectSingleById(int id)
        {
            return this.SelectAll().SingleOrDefault(d => d.id == id);
        }

        public draw SelectSingleByDateAndSyndicateId(DateTime date, int sId)
        {
            return SelectAllBySyndicateId(sId).SingleOrDefault(d => d.drawdate == date);
        }

        public bool InsertDraw(draw d)
        {
            return this.Insert(d);
        }
        public bool UpdateDraw()
        {
            return this.Update();
        }
        public bool DeleteDraw(draw d)
        {
            return this.Delete(d);
        }

    }
}
